package com.blog.backend.service.impl;

import com.blog.backend.mapper.BlogAccessMapper;
import com.blog.backend.resp.BlogAssessResp;
import com.blog.backend.resp.SysSettingResp;
import com.blog.backend.service.BlogAssessService;
import com.blog.backend.utils.PageUtils;
import com.blog.backend.utils.TimeUtils;
import com.blog.backend.vo.PageRequest;
import com.blog.backend.vo.PageResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BlogAssessServiceImpl implements BlogAssessService {

    @Resource
    private BlogAccessMapper blogAccessMapper;
    @Override
    public PageResult<BlogAssessResp> getToDayAssessList(PageRequest request) {
        PageHelper.startPage(request.getPageNum(),request.getPageSize());
        String begin = TimeUtils.getTodayBegin();
        String end = TimeUtils.getTodayEnd();
       List<BlogAssessResp> list= blogAccessMapper.selectTodayAssessList(begin,end);
        PageInfo<BlogAssessResp> info=new PageInfo<BlogAssessResp>(list);
        PageRequest pageRequest = new PageRequest();
        return PageUtils.getPageResult(pageRequest, info);
    }

    @Override
    public PageResult<BlogAssessResp> getAllAssessList(PageRequest request) {
        PageHelper.startPage(request.getPageNum(),request.getPageSize());
        List<BlogAssessResp> list= blogAccessMapper.getAllAssessList();
        PageInfo<BlogAssessResp> info=new PageInfo<BlogAssessResp>(list);
        PageRequest pageRequest = new PageRequest();
        return PageUtils.getPageResult(pageRequest, info);
    }

    @Override
    public BlogAssessResp getAssessDetail(String assessId) {
        BlogAssessResp resp= blogAccessMapper.selectAssessById(assessId);
        return resp;
    }
}
